import React, { useEffect } from 'react'
import { useHistory, useLocation } from 'react-router-dom/cjs/react-router-dom.min'

function Token(Com) {
    return function token(props){
let history=useHistory()
let location=useLocation()
useEffect(()=>{
    if(location.pathname!=='/login'){
        let token=localStorage.getItem('token')
        if(!token){
            history.push('/login')
        }
    }
},[])

        return (
            <div>
                <Com {...props}></Com>
            </div>
          )
    }

}
export default Token